<?php
/* --- Add class of Ngoc --- */
function unFormatDate($d=null , $f="d-m-Y"){
	$d=($d?$d:date("Y-m-d"));
  return date($f,strtotime($d));
}

function formatDate($d=null){
	$arr = explode('-',$d);
	return $arr[2]."-".$arr[1]."-".$arr[0];
}

/*
 * type = x : ngay hien tai tru ngay nhap
 * type = y : ngay nhap tru ngay hien tai
*/
function countDate($start_date, $end_date, $type){
	$nows = mktime(0,0,0,date("m"),date("d"),date("Y"));
	$ngay_nhap = mktime(0,0,0,unFormatdate($start_date,"m"),unFormatdate($start_date,"d"),unFormatdate($start_date,"Y"));				
	$days = ($nows - $ngay_nhap)/86400;
	return $days;
}
?>